<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>逻辑运算符代替条件判断</title>
</head>
<body>
<script>
    function doSomething(arg1) {
        arg1 = arg1 || 10;
// 如果arg1没有值，则取默认值 10
    }

    let foo = 10;
     foo === 10 && doSomething();
     console.log('%c   foo: ','color: MidnightBlue; background: Aquamarine; font-size: 20px;', foo);
    // 如果 foo 等于 10，刚执行 doSomething();
    // 输出: 10

    foo === 5 || doSomething();
    // is the same thing as if (foo != 5) then doSomething();
    // Output: 10
    console.log('%c   foo: ','color: MidnightBlue; background: Aquamarine; font-size: 20px;', foo);

</script>
</body>
</html>